import CopyValue from '@/components/copyValue';
import { Col, Row } from 'antd';
import { engineTitle } from '../constant';
import styles from '../index.less';

interface DataType {
  engineId: string;
  engineName: string;
  cpus: number;
  memory: number;
  enableGpu: string;
  engineImage: string;
  engineLink?: string;
}

interface Props {
  data: DataType;
}
export default function EngineInfo(props: Props) {
  const { data } = props;

  return (
    <>
      {Object.keys(data).map((key) => {
        return (
          <Row key={key} className={styles.row} gutter={[20, 10]}>
            <Col span={6} className={styles.label}>
              {engineTitle[key]}
            </Col>
            <Col span={14} className={styles.content}>
              {data[key]}
              {key === 'engineLink' &&
                (data[key] ? (
                  <CopyValue
                    placement="right"
                    clipboardText={`${engineTitle.engineLink}:${data.engineLink}`}
                    toolTipText="复制"
                  />
                ) : (
                  '暂无'
                ))}
            </Col>
          </Row>
        );
      })}
    </>
  );
}
